package com.dong.controller;

import com.dong.annotation.ExceptionMessageAnnotation;
import com.dong.task.WechatMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.net.URISyntaxException;

/**
 * @author DongJian
 * @date Created in 2020/10/22 14:49
 * Utils: Intellij Idea
 * @description:
 * @version:1.0
 */
@Slf4j
@RestController
public class TestController {

    @Autowired
    WechatMessageUtil dailyTipAndShareTask;

    @ExceptionMessageAnnotation(moduleName = "测试模块", describtion = "测试切面自定义注解是否执行", modulePersonInCharge = "@dongjian")
    @GetMapping("test")
    public String test() {
        log.info("方法执行体,这是一个测试控制器");
        // 制造错误
            int i = 1/0;
        return "i love u";
    }

    /**
     * 发送图文消息
     * @throws Exception
     */
    @GetMapping("/sendNewsMessage")
    public void  sendNewsMessage() throws Exception {
        dailyTipAndShareTask.sendNewsMessage("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a512fa72-7934-4310-8bf0-b91e4d2bb4aa", "中秋节礼品领取",
                "https://doc.weixin.qq.com/txdoc/excel?scode=AKgAagcwAA48ktIrfVAFIA3wYYAJ8&docid=e2_AFIA3wYYAJ8XLx423SgTp0KMDsx60&type=1",
                "今年中秋节公司有豪礼相送",
                "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png");
    }

    /**
     * 发送markdown消息
     * @throws IOException
     * @throws URISyntaxException
     */
    @GetMapping("/sendMarkdownMessage")
    public void sendMarkdownMessage() throws IOException, URISyntaxException {
//        dailyTipAndShareTask.sendMarkDownMessage(null,null);
    }
}
